package com.xbongbong.saas.analytical.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.domain.entity.PaasFormExplainEntity;
import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.help.CommonHelp;
import com.xbongbong.paas.help.FormDataValidateDataHelp;
import com.xbongbong.paas.help.ProSaveHelp;
import com.xbongbong.paas.help.team.TeamUserHelp;
import com.xbongbong.paas.model.PaasFormExplainModel;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.BeanUtil;
import com.xbongbong.paas.toolbox.util.StringUtil;
import com.xbongbong.paas.util.ExplainUtil;
import com.xbongbong.pro.domain.entity.LabelEntity;
import com.xbongbong.pro.enums.DistributorMarkEnum;
import com.xbongbong.pro.enums.errorcodes.ContactErrorCodeEnum;
import com.xbongbong.pro.enums.errorcodes.CustomerErrorCodeEnum;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.pro.formdata.pojo.SaasNeedRedundantAttrPojo;
import com.xbongbong.pro.team.TeamAfterVerifyDTO;
import com.xbongbong.pro.user.pojo.ReturnUserAndDepartmentPojo;
import com.xbongbong.saas.analytical.SaasValidateAnalyticalService;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.enums.LinkAddOperationFlagEnum;
import com.xbongbong.saas.enums.SelectProductEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.SupplierContactEnum;
import com.xbongbong.saas.enums.business.SupplierEnum;
import com.xbongbong.saas.help.AnalyticalHelp;
import com.xbongbong.saas.help.SaasProductHelp;
import com.xbongbong.saas.model.LabelModel;
import com.xbongbong.saas.toolbox.help.FastJsonHelper;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
 * @author 吴峰
 * @date 2021/07/15 17:15
 */
@Service("supplierAnalyticalServiceImpl")
public class SupplierValidateAnalyticalServiceImpl implements SaasValidateAnalyticalService {
    
    private static final Logger LOGGER = LoggerFactory.getLogger(SupplierValidateAnalyticalServiceImpl.class);
    
    @Resource
    private CommonHelp commonHelp;
    @Resource
    private SaasProductHelp saasProductHelp;
    @Resource
    private LabelModel labelModel;
    @Resource
    private PaasFormExplainModel paasFormExplainModel;
    @Resource
    private FormDataValidateDataHelp formDataValidateDataHelp;
    @Resource
    private SupplierContactValidateAnalyticalServiceImpl supplierContactAnalyticalService;
    @Resource
    private TeamUserHelp teamUserHelp;
    @Resource
    private AnalyticalHelp analyticalHelp;

    @Override
    public List<Integer> type() {
        return Arrays.asList(XbbRefTypeEnum.SUPPLIER.getCode());
    }

    @Override
    public void analyticalData(ValidateDataDTO validateDataDTO) throws XbbException {
        beforeSave(validateDataDTO);
        teamUserHelp.beforeVerifyUserTeam(validateDataDTO);
    }
    
    public void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException {
        try {
            JSONObject data = validateDataDTO.getData();
            String corpid = validateDataDTO.getCorpid();
            Long dataId = validateDataDTO.getDataId();
            validateDataDTO.setData(data);
            String name = FastJsonHelper.getStringFromFormData(data, SupplierEnum.SUPPLIER_NAME.getAttr());
            JSONArray productArr = FastJsonHelper.getJsonArrOrDefaultFromFormData(data,SupplierEnum.PRODUCT_LIST.getAttr(),new JSONArray());
            boolean isNew = analyticalHelp.isNew(validateDataDTO.getDataId(), validateDataDTO.getTaskId(), validateDataDTO.getCorpid());
            Boolean productCanSee = true;
            if (!isNew) {
                productCanSee = commonHelp.attrCanSee(validateDataDTO.getExplainMap().get(SupplierEnum.PRODUCT_LIST.getAttr()),validateDataDTO.getDataId(),validateDataDTO.getCreatorId(),validateDataDTO.getLoginUser(),validateDataDTO.getCorpid(),XbbRefTypeEnum.SUPPLIER.getCode());
            }
            if (isNew || productCanSee){
                //新建或编辑可见产品字段
                validateProductDemo(productArr,validateDataDTO.getCorpid());
            }
            // 关联新建
            JSONArray supplierContactArray = FastJsonHelper.getJsonArrFromFormData(data, SupplierEnum.ADD_SUPPLIER_CONTACT.getAttr());
            if (supplierContactArray != null) {
                // 校验联系人
                verifySupplierContact(corpid, supplierContactArray, dataId, name, validateDataDTO, isNew);
            }
            data.put(SupplierEnum.ADD_SUPPLIER_CONTACT.getAttr(), supplierContactArray);
            Map<String,Boolean> attrCanSeeMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            attrCanSeeMap.put(SupplierEnum.PRODUCT_LIST.getAttr(),productCanSee);
            SaasNeedRedundantAttrPojo saasNeedRedundantAttrPojo = validateDataDTO.getSaasNeedRedundantAttrPoJo();
            saasNeedRedundantAttrPojo = saasNeedRedundantAttrPojo == null ? new SaasNeedRedundantAttrPojo(): saasNeedRedundantAttrPojo;
            saasNeedRedundantAttrPojo.setAttrCanSeeMap(attrCanSeeMap);
            validateDataDTO.setSaasNeedRedundantAttrPoJo(saasNeedRedundantAttrPojo);
        } catch (XbbException e) {
            throw e;
        }  catch (Exception e) {
            LOGGER.error("supplierAnalyticalServiceImpl.beforeSave error", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001);
        }
    }

    private void verifySupplierContact(String corpid, JSONArray supplierContactArray, Long dataId, String name, ValidateDataDTO validateDataDTO, Boolean isNew) throws XbbException {
        JSONArray linkSupplierArray = new JSONArray();
        JSONObject linkSupplierObj = new JSONObject();
        linkSupplierObj.put(StringConstant.SAAS_LINK_BUSINESS_ID, dataId);
        linkSupplierObj.put(StringConstant.SAAS_LINK_BUSINESS_NAME, name);
        linkSupplierArray.add(linkSupplierObj);
        PaasFormExplainEntity supplierContactFormExplainEntity = paasFormExplainModel.getByBusinessType(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), corpid);
        Map<String, FieldAttrEntity> supplierContactExplainMap = ExplainUtil.getExplainMap(supplierContactFormExplainEntity.getExplains(), "");

        Integer noRepeat = supplierContactExplainMap.get(SupplierContactEnum.NAME.getAttr()).getNoRepeat();
        if (Objects.nonNull(noRepeat) && Objects.equals(1, noRepeat)){
            Set<String> supplierContactNameSet = new HashSet<>();
            JSONArray supplierContactAddArray = new JSONArray();
            supplierContactArray.forEach(obj -> {
                JSONObject supplierContactObj = (JSONObject) obj;
                // 排除删除联系人的情况，只做新增联系人时排重
                Integer operationFlag = supplierContactObj.getInteger(StringConstant.OPERATION_FLAG);
                if (!Objects.equals(operationFlag, LinkAddOperationFlagEnum.DEL.getCode())) {
                    JSONObject contactData = supplierContactObj.getJSONObject(StringConstant.JSON_DATA);
                    supplierContactNameSet.add(contactData.getString(SupplierContactEnum.NAME.getAttr()));
                    supplierContactAddArray.add(supplierContactObj);
                }
            });
            if (supplierContactNameSet.size() < supplierContactAddArray.size()){
                throw new XbbException(CustomerErrorCodeEnum.API_ERROR_201033);
            }
        }
        // 联系人公共部分属性
        ValidateDataDTO supplierContactValidateDataDTO = new ValidateDataDTO();
        SaasNeedRedundantAttrPojo saasNeedRedundantAttrPojo = new SaasNeedRedundantAttrPojo();
        saasNeedRedundantAttrPojo.setIsRelationItem(1);
        BeanUtil.copyProperties(validateDataDTO, supplierContactValidateDataDTO);
        BeanUtil.copyProperties(supplierContactFormExplainEntity, supplierContactValidateDataDTO);
        String userId = validateDataDTO.getUserId();
        supplierContactValidateDataDTO.setIsNew(isNew);
        supplierContactValidateDataDTO.setExplainMap(supplierContactExplainMap);
        supplierContactValidateDataDTO.setCreatorId(Objects.isNull(validateDataDTO.getCreatorId()) ? validateDataDTO.getUserId() : validateDataDTO.getCreatorId());
        // 每个联系人的data和dataId赋值
        List<ValidateDataDTO> needAddValidateDataDTO = new ArrayList<>();
        List<ValidateDataDTO> needDelValidateDataDTO = new ArrayList<>();
        List<ValidateDataDTO> needUpdateValidateDataDTO = new ArrayList<>();
        List<String> supplierContactPhoneList = new ArrayList<>();
        JSONArray newContactArr = new JSONArray();
        List<String> noRepeatAttr = new ArrayList<>();
        String labelAttr = null;
        Iterator<Map.Entry<String, FieldAttrEntity>> iterator = supplierContactExplainMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, FieldAttrEntity> entry = iterator.next();
            if (Objects.equals(entry.getValue().getNoRepeat(), 1)) {
                noRepeatAttr.add(entry.getKey());
            }
            if (Objects.equals(entry.getValue().getFieldType(), FieldTypeEnum.LABEL.getType())) {
                labelAttr = entry.getValue().getAttr();
            }
        }

        Map<String, Long> labelPojoMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        if (StringUtil.isNotEmpty(labelAttr)) {
            Map<String, Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            param.put("formId", supplierContactFormExplainEntity.getFormId());
            param.put("corpid", supplierContactFormExplainEntity.getCorpid());
            param.put("appId", supplierContactFormExplainEntity.getAppId());
            param.put("del", DelEnum.NORMAL.getDel());
            List<LabelEntity> entitys = labelModel.findEntitys(param);
            entitys.forEach(item->{
                labelPojoMap.put(item.getName(), item.getId());
            });
        }
        Map<String, Long> delPhoneMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        Map<String,  Map<String, Long>> noRepeatMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        int supplierContactNum = supplierContactArray.size();
        for (Object obj : supplierContactArray) {
            // 单个联系人数据
            JSONObject supplierContactObj = (JSONObject) obj;
            // 表示编辑时数据是否被更改，被更改operationFlag为1,被删除operationFlag为2
            Integer operationFlag = supplierContactObj.getInteger(StringConstant.OPERATION_FLAG);
            // 联系人的data数据
            JSONObject contactData = supplierContactObj.getJSONObject(StringConstant.JSON_DATA);
            Long supplierContactDataId = supplierContactObj.getLong(StringConstant.DATA_ID);
            if (StringUtil.isNotEmpty(labelAttr)) {
                String string = contactData.getString(labelAttr);
                if ( Objects.nonNull(string) ) {
                    String[] split = string.split(",");
                    JSONArray jsonArray = new JSONArray();
                    for (String s : split) {
                        if (Objects.nonNull(labelPojoMap.get(s))){
                            jsonArray.add(labelPojoMap.get(s));
                        }
                    }
                    contactData.put(labelAttr, jsonArray);
                }
            }
            if (Objects.equals(operationFlag, LinkAddOperationFlagEnum.DEL.getCode()) && Objects.nonNull(supplierContactDataId)) {
                supplierContactNum--;
                List<String> phoneListFromFormData = FastJsonHelper.getPhoneListFromFormData(contactData, SupplierContactEnum.PHONE.getAttr());
                for (String phone : phoneListFromFormData) {
                    delPhoneMap.put(phone, supplierContactDataId);
                }
                for (String attr : noRepeatAttr) {
                    Map<String, Long> noRepeatDataMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
                    if (noRepeatMap.containsKey(attr)) {
                        noRepeatDataMap = noRepeatMap.get(attr);
                    }
                    noRepeatDataMap.put(contactData.getString(attr), supplierContactDataId);
                    noRepeatMap.put(attr, noRepeatDataMap);
                }
            }
        }
        // 只有一个联系人时，设置该联系人为主联系人
        if (1 == supplierContactNum) {
            JSONObject contactObj = (JSONObject) supplierContactArray.get(0);
            JSONObject data = contactObj.getJSONObject(StringConstant.JSON_DATA);
            data.put(SupplierContactEnum.IS_MAIN.getAttr(), BasicConstant.ONE);
        }
        for (Object obj : supplierContactArray) {
            // 单个联系人数据
            JSONObject supplierContactObj = (JSONObject) obj;
            // 表示编辑时数据是否被更改，被更改operationFlag为1,被删除operationFlag为2
            Integer operationFlag = supplierContactObj.getInteger(StringConstant.OPERATION_FLAG);
            // 联系人的data数据
            JSONObject supplierContactData = supplierContactObj.getJSONObject(StringConstant.JSON_DATA);
            JSONArray originalOwnerJsonArray = supplierContactData.getJSONArray(FieldTypeEnum.OWNERID.getAlias());
            if (Objects.isNull(originalOwnerJsonArray)) {
                String ownerId = supplierContactObj.getString(FieldTypeEnum.OWNERID.getAlias());
                if (StringUtil.isNotEmpty(ownerId)) {
                    originalOwnerJsonArray = new JSONArray();
                    ReturnUserAndDepartmentPojo returnUserAndDepartmentPojo = new ReturnUserAndDepartmentPojo();
                    returnUserAndDepartmentPojo.setId(ownerId);
                    originalOwnerJsonArray.add(returnUserAndDepartmentPojo);
                }
            }
            JSONArray originalCouserJsonArray = supplierContactData.getJSONArray(FieldTypeEnum.COUSERID.getAlias());
            Long supplierContactDataId = supplierContactObj.getLong(StringConstant.DATA_ID);
            supplierContactValidateDataDTO.setDataId(supplierContactDataId);
            supplierContactValidateDataDTO.setImportDelContact(null);

            // 去掉传来的关联客户属性来兼容新建 提前为了让审批数据格式一致
            supplierContactData.remove(SupplierContactEnum.SUPPLIER_ID.getAttr());
            supplierContactData.remove(SupplierContactEnum.SUPPLIER_ID_LINK_TEXT.getAttr());
            supplierContactData.put(SupplierContactEnum.SUPPLIER_ID.getAttr(), linkSupplierArray);
            supplierContactValidateDataDTO.setData(supplierContactData);
            saasNeedRedundantAttrPojo.setContactPhoneList(supplierContactPhoneList);
            supplierContactValidateDataDTO.setSaasNeedRedundantAttrPoJo(saasNeedRedundantAttrPojo);
            ProSaveHelp.analyticalData(supplierContactValidateDataDTO);
            List<String> phoneListFromFormData = FastJsonHelper.getPhoneListFromFormData(supplierContactData, SupplierContactEnum.PHONE.getAttr());
            if (Objects.isNull(supplierContactDataId)) {
                for (String phone : phoneListFromFormData) {
                    if (delPhoneMap.containsKey(phone)) {
                        supplierContactValidateDataDTO.setDataId(delPhoneMap.get(phone));
                        supplierContactValidateDataDTO.setImportDelContact(1);
                    }
                }
                for (String attr : noRepeatAttr) {
                    if ( MapUtils.isNotEmpty(noRepeatMap) &&  noRepeatMap.containsKey(attr)
                            && noRepeatMap.get(attr).containsKey(supplierContactData.getString(attr))) {
                        supplierContactValidateDataDTO.setDataId(noRepeatMap.get(attr).get(supplierContactData.getString(attr)));
                        supplierContactValidateDataDTO.setImportDelContact(1);
                    }
                }
            }
            try {
                // fix: 26324 【成功部】字段填写完整报错报错提示“联系人类型没有填写”
                //  如果联系人已经删除 就跳过此校验
                if (!Objects.equals(operationFlag, LinkAddOperationFlagEnum.DEL.getCode())){
                    formDataValidateDataHelp.validateData(supplierContactValidateDataDTO);
                    //新增、编辑的时候需要校验一下团队
                    supplierContactData.put(FieldTypeEnum.OWNERID.getAlias(), originalOwnerJsonArray);
                    supplierContactData.put(FieldTypeEnum.COUSERID.getAlias(), originalCouserJsonArray);
                    if (!Objects.equals(LinkAddOperationFlagEnum.EDIT.getCode(), operationFlag)) {
                        //web、移动端端新增供应商联系人的时候标识为operationFlag为0, null的时候为编辑
                        if (Objects.equals(BasicConstant.ZERO, operationFlag)) {
                            supplierContactValidateDataDTO.setUserId(validateDataDTO.getUserId());
                            supplierContactValidateDataDTO.setCreatorId(Objects.nonNull(validateDataDTO.getUserId()) ? validateDataDTO.getUserId() : validateDataDTO.getCreatorId());
                            validateTeam(supplierContactData, supplierContactValidateDataDTO, validateDataDTO.getDistributorMark());
                        }else if (Objects.nonNull(supplierContactDataId) && Objects.isNull(operationFlag)) {
                            //做一下兼容，避免由于前端新增的时候操作标识也传了null,所以这时候再加个dataId用于区分
                            supplierContactValidateDataDTO.setCreatorId(supplierContactObj.getString(StringConstant.CREATOR_ID));
                            supplierContactValidateDataDTO.setUserId(supplierContactObj.getString(StringConstant.CREATOR_ID));
                        }else {
                            supplierContactValidateDataDTO.setUserId(validateDataDTO.getUserId());
                            supplierContactValidateDataDTO.setCreatorId(Objects.nonNull(validateDataDTO.getUserId()) ? validateDataDTO.getUserId() : validateDataDTO.getCreatorId());
                            validateTeam(supplierContactData, supplierContactValidateDataDTO, validateDataDTO.getDistributorMark());
                        }
                    }else {
                        supplierContactValidateDataDTO.setUserId(validateDataDTO.getUserId());
                        supplierContactValidateDataDTO.setCreatorId(supplierContactObj.getString(StringConstant.CREATOR_ID));
                        validateTeam(supplierContactData, supplierContactValidateDataDTO, validateDataDTO.getDistributorMark());
                    }
                }
            } catch (XbbException e) {
                if (Objects.equals(e.getCode(), SystemErrorCodeEnum.API_ERROR_100034.getCode())) {
                    throw new XbbException(ContactErrorCodeEnum.API_ERROR_204008);
                } else {
                    throw e;
                }
            }
            supplierContactValidateDataDTO.setIsNew(isNew);
            supplierContactAnalyticalService.beforeSave(supplierContactValidateDataDTO);
            if (Objects.equals(supplierContactValidateDataDTO.getImportDelContact(), 1)) {
                supplierContactValidateDataDTO.setDataId(null);
            }
            supplierContactPhoneList.addAll(phoneListFromFormData);

            if (supplierContactDataId != null) {
                if (Objects.equals(operationFlag, LinkAddOperationFlagEnum.DEL.getCode())) {
                    ValidateDataDTO newDelContactDTO = new ValidateDataDTO();
                    BeanUtil.copyProperties(supplierContactValidateDataDTO, newDelContactDTO);
                    needDelValidateDataDTO.add(newDelContactDTO);
                    continue;
                }
                // 没有更改的的联系人
                if (!Objects.equals(operationFlag, LinkAddOperationFlagEnum.EDIT.getCode())) {
                    continue;
                }
            }

            if (supplierContactDataId != null) {
                ValidateDataDTO newUpdateContactDTO = new ValidateDataDTO();
                BeanUtil.copyProperties(supplierContactValidateDataDTO, newUpdateContactDTO);
                needUpdateValidateDataDTO.add(newUpdateContactDTO);
            } else {
                ValidateDataDTO newAddContactDTO = new ValidateDataDTO();
                BeanUtil.copyProperties(supplierContactValidateDataDTO, newAddContactDTO);
                needAddValidateDataDTO.add(newAddContactDTO);
            }
            newContactArr.add(supplierContactData);
        }
        // 这个是出参，还不能删
        supplierContactArray = newContactArr;
        SaasNeedRedundantAttrPojo customerPojo = new SaasNeedRedundantAttrPojo();
        customerPojo.setNeedAddValidateDataDTO(needAddValidateDataDTO);
        customerPojo.setNeedDelValidateDataDTO(needDelValidateDataDTO);
        customerPojo.setNeedUpdateValidateDataDTO(needUpdateValidateDataDTO);
        validateDataDTO.setSaasNeedRedundantAttrPoJo(customerPojo);
    }
    
    private void validateProductDemo(JSONArray productList, String corpid) throws XbbException {
        Set<Long> pageProductIds = new HashSet<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        for (Object obj : productList){
            JSONObject json = JSONObject.parseObject(obj.toString());
            Long productId = json.getLong(SelectProductEnum.PRODUCT.getAttr());
            pageProductIds.add(productId);
        }
        saasProductHelp.productExit(corpid,new ArrayList<>(pageProductIds));
    }

    /**
     * 校验团队并且往参数中封装团队信息
     *
     * @param json
     * @param validateDataDTO
     * @param distributorMark 经销商标识
     */
    private void validateTeam(JSONObject json, ValidateDataDTO validateDataDTO, Integer distributorMark) throws XbbException {
        if (Objects.equals(distributorMark, DistributorMarkEnum.DISTRIBUTOR.getCode())) {
            return;
        }
        validateDataDTO.setOwnerIds(null);
        validateDataDTO.setCoUserId(null);
        JSONArray teamMainPojoArray = json.getJSONArray(FieldTypeEnum.OWNERID.getAlias());
        JSONArray teamCoPojoArray = json.getJSONArray(FieldTypeEnum.COUSERID.getAlias());
        if (Objects.nonNull(teamMainPojoArray) && teamMainPojoArray.size() > BasicConstant.ZERO) {
            List<ReturnUserAndDepartmentPojo> ownerIds = teamMainPojoArray.toJavaList(ReturnUserAndDepartmentPojo.class);
            validateDataDTO.setOwnerIds(ownerIds);
        }
        if (Objects.nonNull(teamCoPojoArray) && teamCoPojoArray.size() > BasicConstant.ZERO) {
            List<ReturnUserAndDepartmentPojo> coUserIds = teamCoPojoArray.toJavaList(ReturnUserAndDepartmentPojo.class);
            validateDataDTO.setCoUserId(coUserIds);
        }
        try {
            teamUserHelp.beforeVerifyUserTeam(validateDataDTO);
            TeamAfterVerifyDTO teamAfterVerifyDTO = validateDataDTO.getSaasNeedRedundantAttrPoJo().getTeamAfterVerifyDTO();
            SaasNeedRedundantAttrPojo saasNeedRedundantAttrPojo = new SaasNeedRedundantAttrPojo();
            BeanUtil.copyProperties(validateDataDTO.getSaasNeedRedundantAttrPoJo(),saasNeedRedundantAttrPojo);
            saasNeedRedundantAttrPojo.setTeamAfterVerifyDTO(teamAfterVerifyDTO);
            validateDataDTO.setSaasNeedRedundantAttrPoJo(saasNeedRedundantAttrPojo);
            validateDataDTO.setTeamAfterVerifyDTO(teamAfterVerifyDTO);
        } catch (XbbException e) {
            throw new XbbException(e.getCode(), teamUserHelp.formatErrorMessage(e.getCode(), e.getMsg(), XbbRefTypeEnum.SUPPLIER_CONTACT));
        }
    }
}
